package com.h117121.fashionshop.controller.admin;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.h117121.fashionshop.constant.AppConstant;
import com.h117121.fashionshop.controller.generic.GenericController;
import com.h117121.fashionshop.core.dom.ResultPage;

@Controller
@RequestMapping("/admin/home")
public class AdminHomeController extends GenericController {
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView showPage() {
		return new ModelAndView("AdminHomePage");
	}

	@ModelAttribute("newestProducts")
	public ResultPage populateNewestProducts() {
		return businessService.getNewestProducts(0,
				AppConstant.ADMIN_NUM_NEWEST_ITEM);
	}

	@ModelAttribute("mostSoldProducts")
	public ResultPage populateMostSoldProducts() {
		return businessService.getMostSoldProducts(0,
				AppConstant.ADMIN_NUM_MOST_SOLD_ITEM);
	}
}
